package com.monkey.server.sync;

import org.springframework.beans.factory.annotation.Autowired;

import com.monkey.model.Address;
import com.monkey.model.Node;
import com.monkey.server.config.ClusterProperties;
import com.monkey.util.IPUtil;

import lombok.extern.slf4j.Slf4j;

/**
 * @author jurimengs
 */
@Slf4j
public class ParentSynchronizer {
    @Autowired
    private ClusterProperties clusterProperties;

    protected Node getLocalNode() {
        Node node = new Node();
        node.setNodeName(clusterProperties.getNodeName());
        node.setNodeCode(clusterProperties.getNodeCode());
        node.setAddress(getLocalAddress());
        return node;
    }
    
    protected Address getLocalAddress() {
        Address localAddress = new Address();
        localAddress.setHost(IPUtil.getLocalIP());
        localAddress.setPort(clusterProperties.getNettyport());
        return localAddress;
    }
    
}
